#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int sys(char *s) {
	int i = 0, j = strlen(s) - 1;
	for (; i < j; i++, j--)
		if (s[i] != s[j])
			return 0;
	return 1;
}

int main() {
	int n;
	char s[101];
	scanf("%d", &n);
	while (n--) {
		scanf("%s", s);
		while (strlen(s) % 2 == 0 && sys(s))
			s[strlen(s) >> 1] = 0;
		printf("%d\n", strlen(s));
	}
	return 0;
}
